-
-
Notifications
You must be signed in to change notification settings - Fork 320
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Format popover #207
Format popover #207
Conversation
gort818
commented
Oct 28, 2017
- Add a popover for quick switching file formats using gtkmenubutton.
- Update the record button label according to file format chosen.
- Popover menu add to update_shape so users can click the menu
- Added specific styling for users with ambiance theme on ubuntu.
Popover for format options
handle callbacks to button clicks on popover menu for format options
Made the popup format menu the same style as title bar. Thanks Robert!
Add a statement to check if desktop is gnome and change the style of the popover menu. note* need to check other desktops as well.
change popover style from HEADER to TITLEBAR for Gnome.
Users on Ubuntu with ambiance theme need a specific change to the popover theme.
Once you have selected a format the record button label changes to the selected one.
The buttonbox can accept focus
Keep fork up to date
Added ambiance style sheet for ubuntu
ubuntu ambiance styling
load ambiance style sheet for ubuntu
Style group to easily style the whole group
Check user selection of file format and update the record button accordingly.
Keep fork up to date with upstream
Thanks a lot for this :) I will have a look, but it will take a few days. But I definitely want to include this into the next release. |
Awesome! My pleasure :) |
This is a wonderful improvement; I only wish it went even further! The header bar is wasting space at the moment and more than these two buttons can fit. The framerate, which is probably the next most used setting, could also be accommodated:
The widgets in brackets are a button, a dropdown, and a SpinButton, respectively. The text between is just labels. That way, you have a natural language sentence expressing what is going to happen. I also think the widgets should be left-aligned in the header bar instead of centered, which is what other applications using buttons in the header bar (Gedit, Simple Scan) are doing. The center/right area would then be freed up for information like rectangle dimensions, time elapsed, file size estimate(?), or similar, which is currently sorely missing. |
@p-e-w Thanks so much for taking a look, thanks for the feedback. I can definitely do that, but I am thinking it might make the header bar a bit cluttered but I will post a picture of a mock-up and let's see how it looks . Also I saw your 'Simulate a lifeform in the terminal' That is one of the coolest things I have seen in a while. @phw What do you think of the proposed changes? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot for this and sorry that it took so long for me to review it. First off, I like this very much. Feels good and easy to use. I have a few minor refactorings, see comments. And the code needs to be rebased against current master, the build will fail then but only because I moved recorder.output_format
to recorder.config.output_format
, so that's easy to fix.
src/ui/application-window.vala
Outdated
[GtkCallback] | ||
private void on_gif_button_clicked (Button source) { | ||
recorder.output_format="gif"; | ||
record_button.set_label("Record as GIF"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The string must be marked as translatable by wrapping it in _()
, e.g. record_button.set_label(_("Record as GIF"))
. I'd probably also change this to a single base string with printf like
_("Record as %s").printf (_("GIF"))
src/ui/application-window.vala
Outdated
|
||
[GtkCallback] | ||
private void on_gif_button_clicked (Button source) { | ||
recorder.output_format="gif"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I broke this in master branch by adding a recorder.config object. You should rebase this branch against master and change this to recorder..config.output_format
. Btw, that's a nice example of there being no merge conflict, but built will fail anyway ;)
src/ui/application-window.vala
Outdated
record_button.set_label("Record as APNG"); | ||
pop_format.hide(); | ||
} | ||
[GtkCallback] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As this functionality is repeating for all buttons (and maybe there will be even more in the future) I would wrap it in a select_format () helper function, something like this:
private string get_format_name (format) {
switch (format) {
case OUTPUT_FORMAT_APNG: return _("APNG");
case OUTPUT_FORMAT_GIF: return _("GIF");
case OUTPUT_FORMAT_MP4: return _("MP4");
case OUTPUT_FORMAT_WEBM: return _("WebM");
default: return "";
}
}
private void select_format (format) {
recorder.config.output_format = format;
var format_name = get_format_name (format);
record_button.set_label (_("Record as %s").printf (format_name));
pop_format.hide ();
}
That's easier to extend and change in the future.
src/application.vala
Outdated
var theme = new GLib.Settings ("org.gnome.desktop.interface");//grab the users' settings | ||
var theme_name = theme.get_string ("gtk-theme");//find the users' theme | ||
if ( theme_name == "Ambiance" ){ | ||
load_stylesheet_from_uri ("resource:///com/uploadedlobster/peek/css/ambiance.css"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please check the whitespace usage. The Peek code uses spaces and no tabs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oops... Forgot to change my environment
src/ui/application-window.vala
Outdated
@@ -56,10 +64,11 @@ namespace Peek.Ui { | |||
private File out_file; | |||
private RecordingArea active_recording_area; | |||
private string stop_button_label; | |||
|
|||
private string format; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need for this in class scope, this variable is only used once.
src/ui/application-window.vala
Outdated
|
||
//Grab current format and udate the recorder button label to reflect the user's choice | ||
format=settings.get_string("recording-output-format"); | ||
if (format == "gif") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See my comment below for adding a select_format()
method. This could be reused here to avoid duplication of generating the label texts.
In addition I have constants defined for the different formats in defaults.vala
src/ui/application-window.vala
Outdated
var theme_name = theme.get_string ("gtk-theme");//find the users' theme | ||
var pop_style=pop_format.get_style_context(); | ||
if ( theme_name == "Ambiance" ){ | ||
pop_style.add_class(Gtk.STYLE_CLASS_TITLEBAR); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens if we add this for all themes? Does it do any harm?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It does not always behave correctly I have tested with over 10 themes and it is really hit and miss, The only reason I have it set for ambiance because the default for the popover menu was white and it just looked horrible. But now we have an easy way to make changes for specific themes :)
src/ui/application-window.vala
Outdated
//popover menu | ||
if (pop_format.visible) { | ||
var theme = new GLib.Settings ("org.gnome.desktop.interface");//grab the users' settings | ||
var theme_name = theme.get_string ("gtk-theme");//find the users' theme |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd add the above two lines to a static helper function get_theme_name()
in desktop-integration.vala. This way it can be reused in application.vala.
@p-e-w Thanks for the feedback. And kudos for ternimal, clearly one of the coolest things I've seen in a while :)
We don't have too much space here actually :) Even the current record button was considered too large by some. Currently the button's label will hide when you resize the window below a certain threshold (I just noticed this functionality is broken in this branch, but we can fix this up later). So whatever we add here should be (a) secondary functionality and (b) it should hide if there is not enough space to allow for smaller window sizes.
I am not so keen on your frame rate idea, but maybe we have to see how it would look like. But the language structure is a problem in localization. If we want to do this properly we would need to have the button position localizable, and I don't think this helps in getting a consistent interface.
I agree in general, moving the button to the left will give the proper space to other information. Time estimate is definitely missing (#214). Not sure why I would need the dimensions during recording (but maybe display them when not recording, and show time elapsed instead during recording). And I don't think there will be a file size estimate unless somebody comes up with a fairly accurate implementation that works across all formats, encoders and quality settings Peek supports (see also #195). @gort818: if you want to give this a go you are welcome. But I would suggest we get this change merged first and then go on with further restructuring. And as you said, the idea with the many buttons could get cluttered, I would first focus on the moving the button left and show additional info. |
Ok thanks for the review I will get on these changes in the next 2 days. |
Merge with upstream
add a helper function to find the user's theme
@phw Ok I made some changes, please let me know what you think, after this gets merged I would like to work on some more restructuring. |
apparently I cannot spell function. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Functionally, the changes look good, but formatting, indentation and whitespace are all over the place and should be fixed. I have marked only some of the problems, which affect most of the code.
One thing that looks odd to me is that OUTPUT_FORMAT_X
are constants rather than an enum, though I recognize that this was already the case before so if at all it should be resolved independently from this PR.
src/application.vala
Outdated
|
||
if ( DesktopIntegration.get_theme_name() == "Ambiance" ){ | ||
load_stylesheet_from_uri ("resource:///com/uploadedlobster/peek/css/ambiance.css"); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indentation levels of if
and }
do not align.
src/application.vala
Outdated
@@ -274,7 +274,9 @@ namespace Peek { | |||
|
|||
private void load_stylesheets () { | |||
load_stylesheet_from_uri ("resource:///com/uploadedlobster/peek/css/peek.css"); | |||
|
|||
if ( DesktopIntegration.get_theme_name() == "Ambiance" ){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There should be no whitespace after (
and before )
. There should be a space before {
. See the following block.
src/desktop-integration.vala
Outdated
@@ -171,6 +171,14 @@ namespace Peek { | |||
debug ("Desktop: %s", desktop); | |||
return desktop.contains (text); | |||
} | |||
|
|||
public static string get_theme_name () { | |||
var theme = new GLib.Settings ("org.gnome.desktop.interface");//grab the users' settings |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There should be a space before the comment.
src/desktop-integration.vala
Outdated
|
||
public static string get_theme_name () { | ||
var theme = new GLib.Settings ("org.gnome.desktop.interface");//grab the users' settings | ||
var theme_name = theme.get_string ("gtk-theme");//find the users' theme |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indentation level does not align with previous line.
src/ui/application-window.vala
Outdated
@@ -14,6 +14,8 @@ using Gtk; | |||
using Cairo; | |||
using Peek.Recording; | |||
|
|||
|
|||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
?
src/ui/application-window.vala
Outdated
case OUTPUT_FORMAT_MP4: return _("MP4"); | ||
case OUTPUT_FORMAT_WEBM: return _("WebM"); | ||
default: return ""; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indentation.
src/ui/application-window.vala
Outdated
[GtkCallback] | ||
private void on_gif_button_clicked (Button source) { | ||
select_format("gif"); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indentation.
src/ui/application-window.vala
Outdated
|
||
|
||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Too many blank lines.
src/ui/application-window.vala
Outdated
[GtkCallback] | ||
private void on_mp4_button_clicked (Button source) { | ||
select_format("mp4"); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code duplication screams for some kind of unification where the format is a parameter, but I don't know if that's possible when using an XML UI definition.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, if you find a more elegant solution let me know, we could use radiobuttons and group them that is the only option I can think of at the moment.
src/ui/application-window.vala
Outdated
|
||
var pop_format_region = create_region_from_widget (pop_format); | ||
window_region.union (pop_format_region); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indentation.
@phw Ok thanks! Wow I am a mess :( I will get right on that. |
Fixed formatting and white space to coincide with the peek project.
Fixed formatting and white space to coincide with the peek project
Fixed formatting and whitespace to conicide withe the peek project
Changed record Icon from play triangle to red circle for record.
Fixed formatting and white space to coincide with the peek project.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Definitely a big improvement. I left a few more nits but other than those formatting looks OK now.
src/ui/application-window.vala
Outdated
case OUTPUT_FORMAT_MP4: return _("MP4"); | ||
case OUTPUT_FORMAT_WEBM: return _("WebM"); | ||
default: return ""; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indentation does not match switch
.
src/ui/application-window.vala
Outdated
[GtkCallback] | ||
private void on_apng_button_clicked (Button source) { | ||
select_format("apng"); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indentation does not match private
.
src/ui/application-window.vala
Outdated
var pop_style=pop_format.get_style_context(); | ||
if (DesktopIntegration.get_theme_name () == "Ambiance") { | ||
pop_style.add_class(Gtk.STYLE_CLASS_TITLEBAR); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indentation does not match if
.
src/ui/application-window.vala
Outdated
var window_region = create_region_from_widget (recording_view.get_toplevel ()); | ||
var recording_view_region = create_region_from_widget (recording_view); | ||
window_region.subtract (recording_view_region); | ||
|
||
//popover menu | ||
if (pop_format.visible) { | ||
var pop_style=pop_format.get_style_context(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing whitespace around =
.
ui/css/ambiance.css
Outdated
} | ||
|
||
.format_button:hover{ | ||
background-color:#e55d2f; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing indentation.
src/ui/application-window.vala
Outdated
@@ -89,6 +95,8 @@ namespace Peek.Ui { | |||
leave_recording_state (); | |||
}); | |||
|
|||
|
|||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These blank lines were not there before so I think they should be removed. Same below.
src/desktop-integration.vala
Outdated
} | ||
|
||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Too many blank lines, should match spacing between other methods.
src/ui/application-window.vala
Outdated
} | ||
|
||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Too many blank lines.
Added file incorrectly
@p-e-w Thanks! |
Thanks for this, looking good now :) I will give this a final test and merge it than. I'm still pretty busy with work prjects and I need a clear head for peek, so give a few days. And thanks a lot @p-e-w for the detailed review, much appreciated.
I originally wanted to do this as an enum, but than had trouble to figuring out how to bind this to the settings schema and doing string comparison was easier without investing too much time. PRs or suggestions to improve this welcome. |
ui/application-window.ui
Outdated
@@ -31,7 +31,7 @@ Author: Philipp Wolfer <ph.wolfer@gmail.com> | |||
<property name="visible">True</property> | |||
<property name="can_focus">False</property> | |||
<property name="tooltip_text" translatable="yes">Start recording</property> | |||
<property name="icon_name">media-playback-start-symbolic</property> | |||
<property name="icon_name">media-record</property> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not so keen on the look of this, can we change it to media-record-symbolic? Better fits the layout I think.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure it looks good too me.
Just two minor changes. The icon as posted above, and also I noticed that the format is not visible in the button text on initial launch. I think something like
in the constructor should do the trick. UPDATE: Actually |
Switch to the symbolic version of media-record
Set the record button label to the output format on startup.
@phw Done and done :) |
And merged :) Thanks a lot, good work. |
I haven't had too many code contributions so far, but I should start adding an AUTHORS file. Please let me know how you would like to be credited there. |
No problem!
I would be honored! |
@phw You can credit me as Alessandro Toia |